<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class buoihoc_db 
	{
		public function Them($MaBuoiHoc, $MaLopHoc, $NgayHoc, $SoTietHoc)
		{
			$sql = "INSERT INTO `tbl_buoihoc`(`MaBuoiHoc`, `MaLopHoc`, `NgayHoc`, `SoTietHoc`)
					VALUES ('$MaBuoiHoc', '$MaLopHoc', '$NgayHoc', '$SoTietHoc')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($MaBuoiHoc)
		{
			$sql = "DELETE FROM `tbl_buoihoc` WHERE `MaBuoiHoc` = '$MaBuoiHoc'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($MaBuoiHoc, $MaLopHoc, $NgayHoc, $SoTietHoc)
		{
			$sql = "UPDATE `tbl_buoihoc`
					SET `MaLopHoc` = '$MaLopHoc', `NgayHoc` = '$NgayHoc', `SoTietHoc` = '$SoTietHoc'
					WHERE `MaBuoiHoc` = '$MaBuoiHoc'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($MaBuoiHoc, $MaLopHoc, $NgayHoc, $SoTietHoc)
		{
			$sql = "SELECT * FROM `tbl_buoihoc` WHERE 1  ";
			if($MaBuoiHoc != -1)
				$sql .= " AND `MaBuoiHoc` = '$MaBuoiHoc' ";

			if($MaLopHoc != "")
				$sql .= " AND `MaLopHoc` = '$MaLopHoc' ";

			if($NgayHoc != "0000-00-00")
				$sql .= " AND `NgayHoc` = '$NgayHoc' ";

			if($SoTietHoc != -1)
				$sql .= " AND `SoTietHoc` = '$SoTietHoc' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

